package com.guigu.qingcheng.oss.controller;

import com.guigu.qingcheng.oss.service.OssSerivce;
import com.guigu.qingcheng.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss/upload")
@CrossOrigin
public class OssController {
    @Autowired
    private OssSerivce ossSerivce;

    //上传头像的方法
    @PostMapping
    public R uploadOssFile (MultipartFile file) {
        //获取上传文件
        String url = ossSerivce.uploadFileAvatar(file);

        return R.ok().data("url",url);
    }


}
